#ifndef __OTA_MCU_UPGRADE_H__
#define __OTA_MCU_UPGRADE_H__

#define OTA_MCU_BLOCK_SIZE (1024 + 32)
#define OTA_MCU_TIMEOUT    (20000)

/* MCU upgrade status */
#define  OTA_MCU_STATUS_INIT    0x00
#define  OTA_MCU_STATUS_FINISH  0x80

/* MCU data communication command */
#define  OTA_MCU_CMD_VERSION    0x10
#define  OTA_MCU_CMD_READY      0x20
#define  OTA_MCU_CMD_REBOOT     0x30
#define  OTA_MCU_CMD_DATA       0x40

/* MCU command response code */
#define  OTA_MCU_RES_SUCCESS    0x14
#define  OTA_MCU_RES_FAIL       0x15
#define  OTA_MCU_RES_HEAD_ERR   0x16
#define  OTA_MCU_RES_FRAME_ERR  0x17
#define  OTA_MCU_RES_CRC_ERR    0x18
#define  OTA_MCU_RES_WRITE_ERR  0x19
#define  OTA_MCU_RES_MD5_ERR    0x1A
#define  OTA_MCU_RES_ALLOW_UP   0x28

/* MCU upgrade Local HAL for Sub device  */
int ota_mcu_hal_init(void);
int ota_mcu_hal_read(unsigned int *off, unsigned char *buf, unsigned int len);
int ota_mcu_hal_write(unsigned int* off, unsigned char* buf, unsigned int len);

/* MCU HAL transport data with Sub device  */
int ota_mcu_hal_version(void *device, char *version);
int ota_mcu_hal_recv(void* device, unsigned char *buf, unsigned int len);
int ota_mcu_hal_send(void* device, unsigned char *buf, unsigned int len);
int ota_mcu_upgrade_start(unsigned int size, char* ver, char* md5);

/* MCU upgrade main loop */
int ota_mcu_ymodem_upgrade(unsigned int size, char* ver, char* md5);
int ota_mcu_can_upgrade(unsigned int size, char* ver, char* md5);
#endif
